﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CTRLayer;
using ModelLayer;

namespace FredesTestKonsol
{
    class Program
    {
        static CTRCustomer ctrCus;
        static CTRSeat ctrSeat;
        static CTRBooking ctrBook;
        static void Main(string[] args)
        {
            ctrCus = new CTRCustomer();
            ctrSeat = new CTRSeat();
            ctrBook = new CTRBooking();
            //TestGetCustomer();
            //TestGetSeat();
            //testGetAllSeatsOnShow();
            //TestGetBooking();
            TestCreateBooking();
        }

        public static void TestGetCustomer()
        {
            Customer foundCus = null;

            //test data variables
            string phoneNo = "11223344";// known phoneNo from DB

            foundCus = ctrCus.GetCustomerByPhoneNo(phoneNo);
            if (foundCus != null)
            {
                Console.WriteLine("customer found: " + foundCus.FName);
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("customer object is null");
                Console.ReadLine();
            }
        }

        public static void TestGetSeat()
        {
            Seat foundSeat = null;

            //test data variables
            int id = 1;// known seat id from DB

            foundSeat = ctrSeat.GetSeat(id);

            if (foundSeat != null)
            {
                Console.WriteLine("seat found: id: " + foundSeat.SeatId + " status: " + foundSeat.Status);
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("seat object is null");
                Console.ReadLine();
            }
        }

        public static void testGetAllSeatsOnShow()
        {
            List<Seat> foundSeats = new List<Seat>();

            //test data variables
            int id = 1;// known seat id from DB

            foundSeats = ctrSeat.GetAllSeatsOnShow(id);

            if (foundSeats != null)
            {
                Console.WriteLine("seats on show found: ");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("seats list is null");
                Console.ReadLine();
            }
        }

        public static void TestGetBooking()
        {
            Booking foundBook = null;

            //test data variables
            int id = 1;// known seat id from DB

            foundBook = ctrBook.GetBooking(id);

            if (foundBook != null)
            {
                Console.WriteLine("booking found: booking nr: " + foundBook.BookingId + " with employee: " + foundBook.EmpId);
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("booking is null");
                Console.ReadLine();
            }
        }

        public static void TestCreateBooking()
        {
            Booking createdBook = null;

            //test data variables
            int id = 1;// known show id from DB
            int empId = 1111111114; //known employee id from DB
            float totalPrice = 175; //the price to insert in the booking

            createdBook = ctrBook.CreateBooking(id, empId, totalPrice);

            if (createdBook != null)
            {
                Console.WriteLine("created booking with booking id: " + createdBook.BookingId + "with show id: " + createdBook.PbList.Find(item => item.Id == 1) + " with employee id : " + createdBook.EmpId);
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("booking is null");
                Console.ReadLine();
            }
        }
    }
}
